< previous page page_612 next page >

Page 612
To see if a ray intersects the checkerboard, this class calculates the intersection between the ray and its plane just as the RayPlane, RayDisk, and RayPolygon classes do. It then plugs the coordinates of the point of intersection into the previous equations and solves for the values i and j. If those values indicate that the point lies on one of the object's rectangular areas, the FindT function returns the parameter t indicating the point's distance along the ray. If the i and j values indicate the point does not lie on one of the object's squares, FindT returns 1 to indicate there is no useful intersection. The following code shows how the FindT function works.
e10a6a0a59f035e870d90cca05b85fce.gif
' Return the value T for the point of intersection
' between the vector from point (px, py, pz) in
' the direction <vx, vy, vz>.
'
' direct_calculation is true if we are finding the
' intersection from a viewing position ray. It is
' false if we are finding a reflected intersection
' or a shadow feeler.
Public Function RayTraceable_FindT( _ 
    ByVal direct_calculation As Boolean, _ 
    ByVal px As Single, ByVal py As Single, _ 
    ByVal pz As Single, ByVal Vx As Single, _ 
    ByVal Vy As Single, ByVal Vz As Single) As Single 
Dim A As Single
Dim B As Single
Dim C As Single
Dim D As Single
Dim Nx As Single
Dim Ny As Single
Dim Nz As Single
Dim denom As Single
Dim t As Single
Dim Cx As Single
Dim Cy As Single
Dim Cz As Single
Dim dx As Single
Dim dy As Single
Dim dz As Single
Dim X As Single
Dim Y As Single
Dim Z As Single
Dim v1x As Single
Dim v1y As Single
Dim v1z As Single
Dim v2x As Single
Dim v2y As Single
Dim v2z As Single
Dim i As Single
Dim j As Single

    ' See if we have been culled.
    If direct_calculation And DoneOnThisScanline Then

 
< previous page page_612 next page >